package getui

import (
	"data/view/user"
	"public/message"
	"public/tools"

	"github.com/ant0ine/go-json-rest/rest"
)

//绑定信息
func BindGetui(w rest.ResponseWriter, r *rest.Request) {
	var req Req_Getui_bind
	tools.GetRequestJsonObj(r, &req)

	//参数检测
	if !tools.CheckParam(req.Access_token, req.ClientID) {
		w.WriteJson(message.GetSuccessMsg())
		return
	}

	//验证token，并获取用户名
	username, _, bfind := user.GetUserFromToken(req.Access_token) //GetUserFromToken()
	if !bfind {
		w.WriteJson(message.GetSuccessMsg())
		return
	}

	OnBindGetui(username, req.ClientID)
	w.WriteJson(message.GetSuccessMsg())
}
